Client level means
if not `Client: wipe out`, no erase; if so, erase.
local objects = {
{tag = "mytask", ref="task1", content = "Buy groceries"},
{tag = "mytask", ref="task2", content = "Write docs"}
}
index.indexObjects("my page", objects)
\({index.queryLuaObjects("mytask", {limit=3})}
\){index.getObjectByRef("my page", "mytask", "task1")}
上述看上去是永久的,哪怕你 Client: wipe out。
但:如果你 只运行一次
${index.indexObjects("my page", {
{tag = "mytask", ref="task1", content = "Buy groceries"},
{tag = "mytask", ref="task2", content = "Write docs"}
})}
然后删除这段。
再运行一次
${index.queryLuaObjects("mytask", {limit=3})}
你会发现有你想要的 table。
但仍然删除这段。
然后关闭 SB,再打开,你发现还是有,说明已经写入 indexdb 里了。 只要 indexdb 里有,且有 indexdb,那就是有。
然而你一旦 Client: wipe out,就会发现没了。
除非你再执行一次
${index.indexObjects("my page", {
{tag = "mytask", ref="task1", content = "Buy groceries"},
{tag = "mytask", ref="task2", content = "Write docs"}
})}
以写入 indexdb 。
因为 每次 login SB 后,除了 可能的 reindex, Client 它还要把 每一个 space-lua 块 全都 加载一次的嘛!
是因为 下述 新增的 attr 重开 SB 就没了么?
-- priority: -1
-- 这个 index.defineTag 和 config.define 一样,会互相覆盖。
-- 但 index.defineTag 的语法 却更像 command.define
index.defineTag {
name = "page",
metatable = {
__index = function(self, attr)
if attr == "loudName" then
return string.upper(self.name)
end
end
}
}
如果不 select,单从表中 看不出 loudName 这个 attr: \({query[from index.tag "page" limit 3](from index.tag "page" limit 3)} 肯定不是呀!你刷新后不还有么。 \){queryfrom index.tag "page" select {name=.name, loudName=.loudName} limit 3} 问题在这:每次加载 SB 后,Library/xczphysics/CONFIG/Add_Fields_for_Obj/Last_Opened-Page 中的
local lastVisitStore = lastVisitStore or {}
会 lastVisitStore = {},因为 刚开始 没有 lastVisitStore
一旦定义了 lastVisitStore,SB 跑着跑着就 往 lastVisitStore 里存values
那么,一旦这个问题(的根源)被描述清楚了,则:谜底写在谜面上 - 需要将 lastVisitStore 长久化储存, - 或者直接 string.upper(self.name) 一样 依附于 另一个 attr。 - 对于 lastVisit 可以 依附于 lastOpened,甚至直接实时转换 - 但对于 VisitTimes 呢?